package com.liu.yuoj.judge.codesandbox.impl;

import com.liu.yuoj.common.ErrorCode;
import com.liu.yuoj.exception.BusinessException;
import com.liu.yuoj.judge.codesandbox.CodeSandBox;
import com.liu.yuoj.judge.codesandbox.model.ExecuteCodeRequest;
import com.liu.yuoj.judge.codesandbox.model.ExecuteCodeResponse;
import com.liu.yuoj.model.dto.questionsubmit.JudgeInfo;

import java.util.List;

/**
 * @author 刘渠好
 * @since 2025-01-15 22:15
 * 代码沙箱(举例，为了是跑通流程)
 */
public class ExampleCodeSandBox implements CodeSandBox {
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest request) {
        if (request==null){
            throw new BusinessException (ErrorCode.PARAMS_ERROR);
        }
        List<String> input = request.getInput ();
        ExecuteCodeResponse build = ExecuteCodeResponse.builder ()
                .output (input)
                .message ("执行成功！")
                .judgeInfo (new JudgeInfo ())
                .status (0)
                .build ();
        return build;
    }
}
